package com.yanyan.sannuomin.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yanyan.sannuomin.result.Result;
import com.yanyan.sannuomin.result.ResultCode;
import com.yanyan.sannuomin.service.RoleService;
import com.yanyan.sannuomin.vo.RoleVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/role")
@Api(tags = "权限信息")
public class RoleController {
    @Resource
    private RoleService roleService;

    @RequestMapping(value = "findRole",method = RequestMethod.GET)
    @ApiOperation(value = "查询菜单",httpMethod = "GET")
    public Result findRole(Integer page,Integer limit) throws Exception{
        ObjectMapper objectMapper=new ObjectMapper();
        Page page1= PageHelper.startPage(page,limit);
        List<RoleVo> roleVos=roleService.findRole();
        PageInfo pageInfo=new PageInfo(roleVos);
        return  Result.ok(ResultCode.SUCCESS,pageInfo.getTotal(),roleVos);
    }
}
